package controllers

import (
	"github.com/astaxie/beego"
	"beeblog/models"
)

type ReplyController struct {
	beego.Controller
}

func (this *ReplyController) Add() {
	flag := checkAccount(this.Ctx)
	if !flag {
		this.Redirect("/login", 302)
		return
	}
	tid := this.Input().Get("tid")
	name := this.Input().Get("nickname")
	content := this.Input().Get("content")
	err := models.AddReply(tid,name,content)
	if err!= nil{
		beego.Error(err)
	}

	this.Redirect("/topic",302)
}

func (this *ReplyController) Delete() {
	Id := this.Input().Get("rid")
	Tid := this.Input().Get("tid")
	err := models.DeleteReply(Tid,Id)
	if err!= nil{
		beego.Error(err)
	}

	this.Redirect("/topic/view/"+Tid,302)
}